package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author stone
 * @date 2021/11/22 16:21
 */
@Controller
public class HelloController {

    //如果没有增加@ResponseBody注解，返回值字符串 作为视图名的
    @RequestMapping("hello")
    public String hello() {
        return "/hello.jsp"; //ModelAndView，其中视图名 /hello.jsp
    }

    //如果增加了@ResponseBody注解，返回值字符串是直接输出的
    @ResponseBody
    @RequestMapping("hello2")
    public String hello2() {
        return "hello2 hello2 松哥";
    }

    @ResponseBody
    @RequestMapping("hello3")
    public BaseRespVo hello3() {
        return BaseRespVo.ok("松哥");
    }
}
